<template>
    <Modal v-model="visible" title="救助对象花名册查验" width="600" :key="key">
        <Form :label-width="150">
            <FormItem label="计划查验时间:" prop="ssfc0014">
                <DatePicker v-model="ssfc0014" class="itemStyle" :options="options3"
                            format="yyyy-MM-dd" :editable="false"></DatePicker>
            </FormItem>
        </Form>
        <div slot="footer">
            <Button type="text" size="large" @click="visible=false">取消</Button>
            <Button type="primary" size="large" @click="handleCheckSubmit()">确定</Button>
        </div>
    </Modal>
</template>

<script>
  import { CommonMixin } from '@/views/common/js/CommonMixin'
  import DateFormat from '@/plugins/format.js'
  import { postAction } from '@/api/request'

  export default {
    mixins: [CommonMixin],
    name: 'check-plan',
    data () {
      return {
        visible: false,
        title: '救助对象花名册查验设置',
        key: '',
        ssfc0014: '',
        ss18900Id: '',
        url: {
          makeCheckPlan: '/api/ac/subsistence/ss18900Service/updateAndMakeCheckPlan'
        },
        //查验计划时间，设置不可选择的日期
        options3: {
          disabledDate (date) {
            let nowTime = new Date()
            let month = nowTime.getMonth() + 1
            let year = nowTime.getFullYear()
            let day = nowTime.getDate() + 1
            if (month - 1 == 0) {
              year = year - 1
              month = 12
            }
            return date && date.valueOf() < new Date(`${year}-${month}-${day}`)
          }
        },

      }
    },
    methods: {
      edit (row) {
        this.ss18900Id = row.id
        this.visible = true
      },
      cancel () {
        this.visible = false
      },
      //花名册查验计划
      handleCheckSubmit () {
        if (this.ssfc0014 == '' || this.ssfc0014 == undefined) {
          this.$Message.error('请录入计划查验时间！')
        } else {
          var dataParam = {
            ss189001Id: this.ss18900Id,
            ssfc0014: DateFormat(this.ssfc0014, 'YYYY-MM-DD')
          }
          postAction(this.url.makeCheckPlan, dataParam).then((res) => {
            this.$Message.success('制定查验计划成功！')
            this.visible = false
            this.$parent.loadData(1)
          })
        }
      },
    }
  }
</script>

<style scoped>

</style>
